home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
tex
/
td187src.lzh
/
COMPILE.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
43KB
|
1,311 lines
IMPLEMENTATION MODULE Compile ;
(* Erweitert um Beziercurve, JP *)
(* Erweitert um Epic-Kommandos, JP *)
FROM Dialoge IMPORT BusyStart, BusyEnd;
FROM FileIO IMPORT Rewrite, Close, WriteLn;
FROM File IMPORT InsertFile;
FROM CSspecial IMPORT WriteCSspecial;
FROM Types IMPORT TextPosTyp, DrawObjectTyp, ObjectSet,
LatexSpecials,
ObjectPtrTyp, specialformat;
IMPORT CommonData ;
IMPORT Diverses ;
IMPORT GetFile;
IMPORT ObjectUtilities ;
IMPORT MagicStrings;
IMPORT MagicSys;
IMPORT Variablen ;
IMPORT MathLib0 ;
(**
IMPORT Debug;
**)
(* Index 1 und 2 bezeichen immer den Referenzpunkt *)
(* Index 8 zumeist die Liniendicke, Index 9 die Textlänge so vorhanden *)
(* 0 | 3 | 4 | 5 | 6 | 7 | 8 | 9 *)
(* ---------------+--------+-------+---------------+-------+-------+------ *)
(* Picture | XExt | YExt |objekte|unitlen| | | *)
(* Text | | | | |AlignFl| |Textlen*)
(* Line | | | | | | | *)
(* Arrow | | | | | | | *)
(* Circle | Radius | | | | | | *)
(* Disk | Radius | | | | | | *)
(* Oval | Radius | Posit.| | | | | *)
(* Filledbox | XExt | XExt | | | | | *)
(* Ovalbox | XExt | YExt | | | | | *)
(* Framebox | XExt | YExt |Textpos|MBxFlag|AlignFl| |Textlen*)
(* Dashbox | XExt | Yext |Textpos| |AlignFl| |Textlen*)
(* Beziercurve | X2 | Y2 | X3 | Y3 |Points | | *)
(* Bezierellipse | X2 | Y2 | X3 | Y3 |Points | | *)
(* EpicSolidLine | Pts-1 | | | | | |MarkTL *)
(* EpicDottedLine | Pts-1 | | | | | | " *)
(* EpicDashedLine | Pts-1 | | | | | | " *)
(* EpicGrid | Xext | YExt |DeltaX |DeltaY | | | *)
(* Arc | Radius |StartA.|DeltaA.| | | | *)
(* Spline | Pts-1 | | | | | | *)
(* Ellipse | XRadius|YRadius|StartA.|DeltaA.| | | *)
CONST FullCSName = TRUE; (* Beim special-Befehl Pfad mit übergeben *)
CONST Clever = TRUE; (* Doppelpfeile durch einfaches hinzufügen *)
(* einer zweiten Pfeilspitze erzeugen (TRUE) *)
(* oder durch 2 Pfeile darstellen (FALSE)? *)
VAR OutLine, Part,
CSName,
String : ARRAY [0..255] OF CHAR ;
Handle,
i , j : INTEGER ;
Object : ObjectPtrTyp ;
Width : INTEGER ; (* Liniendicke *)
TextOnly : BOOLEAN ;
Flag1 : BOOLEAN ;
Flag2 : BOOLEAN ;
UseCSspecial,
UseEEPiC : BOOLEAN ;
CompileEm : ARRAY specialformat,
DrawObjectTyp OF BOOLEAN;
(**
PROCEDURE AppendChar(c : CHAR; VAR target : ARRAY OF CHAR);
VAR temp : ARRAY [0..1] OF CHAR;
BEGIN
temp[0] := c;
temp[1] := 0C;
MagicStrings.Append(temp, target);
END AppendChar;
**)
(**********************************************************)
PROCEDURE Position ( Pos : INTEGER ; VAR Str : ARRAY OF CHAR ) ;
BEGIN
CASE VAL(TextPosTyp, Pos) OF
LeftTop : MagicStrings.Assign ( '[tl]', Str); |
Left : MagicStrings.Assign ( '[l]', Str); |
LeftBot : MagicStrings.Assign ( '[bl]', Str); |
Top : MagicStrings.Assign ( '[t]', Str); |
Bottom : MagicStrings.Assign ( '[b]', Str); |
RightTop : MagicStrings.Assign ( '[tr]', Str); |
Right : MagicStrings.Assign ( '[r]', Str); |
RightBot : MagicStrings.Assign ( '[br]', Str); |
ELSE
MagicStrings.Assign ( '', Str);
END;
END Position ;
PROCEDURE BasicGetPut(x, y : INTEGER);
BEGIN
OutLine := "\put(,)" ; (* Anfangskoordinaten *)
Variablen.SimpleValueToStr ( y , String ) ;
MagicStrings.Insert ( String , OutLine , 6 ) ;
Variablen.SimpleValueToStr ( x , String ) ;
MagicStrings.Insert ( String , OutLine , 5 ) ;
END BasicGetPut;
PROCEDURE Basic10GetPut(x, y : MagicSys.lINTEGER);
BEGIN
OutLine := "\put(,)" ; (* Anfangskoordinaten *)
Variablen.SimpleValue10ToStr ( y , String ) ;
MagicStrings.Insert ( String , OutLine , 6 ) ;
Variablen.SimpleValue10ToStr ( x , String ) ;
MagicStrings.Insert ( String , OutLine , 5 ) ;
END Basic10GetPut;
PROCEDURE GetPut ( Object : ObjectPtrTyp ) ;
BEGIN
BasicGetPut(Object^.Code[1], Object^.Code[2]);
END GetPut;
PROCEDURE GetText( Object : ObjectPtrTyp;
VAR result : ARRAY OF CHAR) ;
VAR temp : ARRAY [0..255] OF CHAR;
insert : ARRAY [0..19] OF CHAR;
align : INTEGER;
cr : BOOLEAN;
i, j, len : INTEGER;
BEGIN
temp := '';
cr := FALSE;
len := Object^.Code[9];
align := Object^.Code[7];
FOR i := 0 TO len-1 DO
temp [ i ] := Object^.CPtr^ [ i ] ;
END ;
temp [ len ] := 0C ;
FOR i:=0 TO len-2 DO
IF (temp[i]='\') AND (temp[i+1]='\') THEN
cr := TRUE;
END;
END;
IF cr THEN
insert := '';
CASE align OF
0: (* center *) insert := '\shortstack{'; |
1: (* leftalign *) insert := '\shortstack[l]{'; |
2: (* rightalign *) insert := '\shortstack[r]{'; |
ELSE
END;
IF insert[0]<>0C THEN
MagicStrings.Insert(insert, temp, 0);
(* AppendChar ('}', temp);*)
MagicStrings.Append('}', temp);
END;
END;
MagicStrings.Assign ( temp, result);
END GetText;
PROCEDURE ArrowHead(x1, y1, x2, y2 : INTEGER;
start, end : BOOLEAN);
(* LaTeX erlaubt die Steigungspaare von (-4..+4,-4..+4) wobei
die Werte keinen gemeinsamen Teiler haben dürfen *)
VAR mx, my : INTEGER;
dx, dy : INTEGER;
i, j : INTEGER;
a1, e1,
a2, e2 : INTEGER;
slope : ARRAY [-4..+4],[-4..+4] OF LONGREAL;
testslope : LONGREAL;
delta : LONGREAL;
BEGIN
FOR mx := -4 TO 4 DO
FOR my := -4 TO 4 DO
IF mx<>0 THEN
slope[mx,my] := MathLib0.real(my) / MathLib0.real(mx) ;
ELSE
IF mx>=0 THEN
slope[mx,my] := +9999.99
ELSE
slope[mx,my] := -9999.99
END;
END;
END;
END;
(* Also: zunaechst einmal Steigung bestimmen *)
dx := x2 - x1;
dy := y2 - y1;
IF dx<0 THEN
a1 := -4;
e1 := 0;
ELSE
a1 := 0;
e1 := +4;
END;
IF dy<0 THEN
a2 := -4;
e2 := 0;
ELSE
a2 := 0;
e2 := +4;
END;
(* Sonderfälle abfangen *)
IF dx = 0 THEN
mx := 0;
IF dy<0 THEN
my := -1;
ELSE
my := +1;
END;
ELSIF dy = 0 THEN
my := 0;
IF dx<0 THEN
mx := -1;
ELSE
mx := +1;
END;
ELSE
testslope := MathLib0.real(dy) / MathLib0.real(dx);
(* So welcher Wert liegt nahe *)
mx := 0;
my := 0;
delta := 9999.99;
FOR i:=a1 TO e1 DO
FOR j:=a2 TO e2 DO
IF ABS(slope[i,j] - testslope)<delta THEN
delta := ABS(slope[i,j] - testslope);
mx := i;
my := j;
END;
END;
END;
END;
IF NOT ((mx=0) AND (my=0)) THEN
(* So jetzt eventuell Bruch reduzieren *)
IF (mx<>0) AND (my<>0) THEN
WHILE ((mx MOD 2) = 0) AND ((my MOD 2) =0) DO
(* Es können nur Vielfache von 2 sein *)
mx := mx DIV 2;
my := my DIV 2;
END;
END;
END;
IF start THEN
BasicGetPut(x1, y1);
Part := '{\vector(,){0}}';
Variablen.NumberToStr ( -my , String ) ;
MagicStrings.Insert ( String , Part , 10 ) ;
Variablen.NumberToStr ( -mx , String ) ;
MagicStrings.Insert ( String , Part , 9 ) ;
MagicStrings.Append ( Part , OutLine ) ;
WriteLn ( Handle